[READ-ONLY] Mirror of https://github.com/flo-bit/skywatched. review movies and tv shows, based on at proto skywatched.app
0

Configure Feed

Select the types of activity you want to include in your feed.

skywatched / src / routes / user / [handle] / +page.server.ts
1.0 kB 41 lines
1import { getProfile, resolveHandle, getFollows } from '$lib/bluesky.js'; 2import { getRecentRecordOfUser, getAuthorDids } from '$lib/db'; 3 4/** @type {import('./$types').PageServerLoad} */ 5export async function load(event) { 6 const handle = event.params.handle; 7 8 const did = await resolveHandle({ handle: handle }); 9 10 const profilePromise = getProfile({ did }); 11 const reviewsPromise = getRecentRecordOfUser({ did }); 12 13 const authorsPromise = getAuthorDids(); 14 15 const [profile, reviews, authors] = await Promise.all([ 16 profilePromise, 17 reviewsPromise, 18 authorsPromise 19 ]); 20 21 if (event.locals.user) { 22 const follows = await getFollows({ did: event.locals.user.did }); 23 24 return { 25 isUser: event.locals.user?.did === did, 26 username: event.params.handle, 27 profile, 28 items: reviews, 29 follows: follows.follows.filter((profile) => authors.includes(profile.did)), 30 following: follows.follows.some((profile) => profile.did == did), 31 did 32 }; 33 } 34 35 return { 36 isUser: false, 37 profile, 38 items: reviews, 39 did 40 }; 41}